package com.by.service.common.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.by.entity.common.Category;
import com.by.mapper.common.CategoryMapper;
import com.by.service.common.CategoryService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {


    @Override
    public List queryCategoryTree(String pid) {
        Map map = new HashMap();
        map.put("pid", pid);
        map.put("rs", "");
        baseMapper.queryCategoryTree(map);
        System.out.println(map);
        System.out.println(map.get("rs"));
        ObjectMapper objectMapper = new ObjectMapper();
        List list = null;
        try {
            list = objectMapper.readValue(map.get("rs").toString(), List.class);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return list;
    }
}
